{% extends "base.html" %}
{% load staticfiles %}

{% block title %}
	图灵课程 - 主页
{% endblock %}

{% block style %}
    <style type="text/css">
        .pre-scrollable{
            max-height: 340px;
            overflow-y: scroll;
        }
    </style>
{% endblock %}

{% block content %}
<div class="" style="width:450px;padding-top: 5px">  
    <table cellpadding="0" cellspacing="0" style="width:450px;" id="optionContainer">  
        <tr id="option1">   
            <td class="oz-form-topLabel">选项1：</td>  
            <td class="oz-property" >  
                <input type="text"  style="width:300px">  
            </td>  
            <td></td>  
        </tr>  
        <tr id="option2">   
            <td class="oz-form-topLabel">选项2222：</td>  
            <td class="oz-property">  
                <input type="text"  style="width:300px" >  
            </td>  
            <td></td>  
        </tr>  
        <tr id="option3">   
            <td class="oz-form-topLabel">选项3：</td>  
            <td class="oz-property" >  
                <input type="text"  style="width:300px">  
            </td>  
            <td></td>  
        </tr>  
        <tr id="option4">   
            <td class="oz-form-topLabel">选项4：</td>  
            <td class="oz-property" >  
                <input type="text"  style="width:300px">  
            </td>  
            <td></td>  
        </tr>  
    </table>  
    <div style="text-align: center;">  
        <a href="#" onclick="addRow()">添加一行</a>  
    </div>  
</div> 
<!-- 代码显示 -->
<div class="row">
    <div class="col-md-2"></div>
    <div class="col-md-8">
        <!-- pre: java php（针对多行代码） -->
        <pre class="pre-scrollable">
class ArticleAdmin(admin.ModelAdmin):
    ## 设置[django-admin]标签
    ## list_display 在界面上显示的内容
    ## ordering 根据哪个属性进行排序
    ## actions 显示在界面上的“Aciton”处，点击可触发相应的函数
    list_display = ['title', 'body','status']
    ordering = ['title']
    actions = ['make_published', 'make_draft']

    # 已选中对象集合为参数的回调函数
    def make_published(self, request, queryset):
        rows_updated = queryset.update(status = 'p')
        if rows_updated == 1:
            message_bit = "1 story was"
        else:
            message_bit = "%s stories were" % rows_updated
        self.message_user(request, "%s successfully marked as published." % message_bit)


    def make_draft(self, request, queryset):
        rows_updated = queryset.update(status = 'd')
        if rows_updated == 1:
            message_bit = "1 story was"
        else:
            message_bit = "%s stories were" % rows_updated
        self.message_user(request, "%s successfully marked as drafted." % message_bit)

admin.site.register(Article, ArticleAdmin)
        </pre>

        <!-- code: 单个单词或者单个句子的代码 -->
        <code>

        </code>

        <!-- kbd:一般是表示用户要通过键盘输入的内容 -->
        <kbd>
            
        </kbd>
    </div>
</div>


{% endblock %}

{% block other_script %}
	<script>
		var rowCount=4;  //行数默认4行  

		//添加行  
		function addRow(){  
		    rowCount++;  
		    var newRow='<tr id="option'+rowCount+'"><td class="oz-form-topLabel">选项'+rowCount+'：</td><td class="oz-property" ><input type="text"  style="width:300px"></td><td><a href="#" onclick=delRow('+rowCount+')>删除</a></td></tr>';  
		    $('#optionContainer').append(newRow);  
		}  
		  
		//删除行  
		function delRow(rowIndex){  
		    $("#option"+rowIndex).remove();  
		    rowCount--;  
		}  
	</script>
{% endblock %}